<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>tl-ops-manage后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script src="../lib/layui/layui.js" v="layui" e="layui"></script>
    <link rel="stylesheet" type="text/css" href="../lib/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="../lib/layui/component/inputtag/inputTag.css">
</head>
<style>
    .layui-form-pane .layui-form-label {
        width: 160px;
    }
    .layui-form-pane .layui-input-block {
        margin-left: 160px;
    }
    input {
        color: darkorchid;
        font-weight: 700;
    }
    .tl-icon-font{
        border-radius: 23px;
        padding: 2px;
        font-size: 12px;
        background: burlywood;
        cursor: pointer;
    }
</style>
<body>

    <div class="layui-form layui-form-pane" lay-filter="tl-ops-web-plugins-form" id="tl-ops-web-plugins-form" style="padding: 20px 20px 0px 20px;">
        <div class="layui-form-item" style="display: none;">
            <label class="layui-form-label">插件名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" class="layui-input" placeholder="请输入插件名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">生命周期</label>
            <div class="layui-input-block">
                <input type="text" name="scope" style="display: none" class="layui-input" autocomplete="off" value="">
                <div class="fairy-tag-container" >
                    <input type="text" class="fairy-tag-input scope" autocomplete="off" value="">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">配置页面</label>
            <div class="layui-input-block">
                <input type="text" name="page" class="layui-input" placeholder="请输入配置页面">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">中文名称</label>
            <div class="layui-input-block">
                <input type="text" name="zname" class="layui-input" placeholder="请输入中文名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" name="open" id="open" lay-skin="switch" lay-text="启用中|已关闭" >
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="tl-ops-web-plugins-form-submit" id="tl-ops-web-plugins-form-submit" value="确认">
        </div>
    </div>

    <script src="../lib/tl_ops_web_comm.js"></script>
    <script>
        layui.use(['table', 'form', 'layedit'], function () {
            window.form = layui.form;

            window.tl_ops_web_plugins_form_render = function(data){
                form.val("tl-ops-web-plugins-form", Object.assign(form.val("tl-ops-web-plugins-form"), data))
                // 渲染生命周期tag
                tl_write_article_render_scope(data)
                form.render()
            }
        })

        
        //渲染scope
        const tl_write_article_render_scope = function (data) {
            let initScopeData = []
            if(data.scope && data.scope.indexOf(",") > -1){
                initScopeData = data.scope.split(",")
            }else if(data.scope && data.scope !== ''){
                initScopeData = [data.scope]
            }
            
            layui.config({
                base: '../lib/layui/component/inputtag/'
            }).use(['inputTag', 'jquery'], function () {
                let $ = layui.jquery, inputTag = layui.inputTag;
                inputTag.render({
                    elem: '.scope',
                    data: initScopeData,
                    permanentData: [],
                    removeKeyNum: 8,
                    createKeyNum: 13,
                    clearBeforeRender : true,
                    placeholder : data.zname + "生命周期",
                    onChange: (value, type, text) => {
                        $("input[name=scope]").val(value)
                    }
                });
            });
        };

    </script>
</body>

</html>